import { Spin } from 'antd';
import { Component } from 'react';

export default class index extends Component {
  loading = false;
  render() {
    const { children, loading } = this.props;
    if (toolbar.isPromise(loading) && this.loadingPromise !== loading) {
      this.loadingPromise = loading;
      this.loading = true;
      loading.finally(() => {
        this.loading = false;
        this.setState({});
      });
    }

    return <Spin spinning={this.loading}>{children}</Spin>;
  }
}
